#include "../process.h"
#include "../util.h"

int main(int argc, const char* argv[])
{
	fstream input(argv[1], fstream::in);
	fstream output(argv[2], fstream::out);

	map<int, vector<string>> ranker;
	map<int, vector<string>>::iterator itr;
	while(!input.eof())
	{
		string line;
		getline(input, line);
		int del = line.find("\t");
		int freq = atoi(line.substr(0, del).c_str());
		itr = ranker.find(-freq);
		if(itr == ranker.end())
		{
			vector<string> v;
			v.push_back(line);
			ranker.insert(pair<int, vector<string>>(-freq, v));
		}
		else
			(*itr).second.push_back(line);
	}
	for(itr = ranker.begin(); itr != ranker.end(); ++ itr)
		for(int i = 0; i < (*itr).second.size(); ++ i)
			output << (*itr).second[i] << endl;
	input.close();
	output.close();
	return 0;
}